import qs from 'qs'
import moment from 'moment'
import { axios as request  } from '@/utils/request'

export function getList({params}) {
  //用moment格式化时间yyyy-MM-dd HH:mm:ss
  params.beginSearchTime = moment(params.beginSearchTime).format('YYYY-MM-DD HH:mm:ss')
  params.endSearchTime = moment(params.endSearchTime).format('YYYY-MM-DD HH:mm:ss')
  params.operatorEndSearchTime = params.operatorEndSearchTime? moment(params.operatorEndSearchTime).format('YYYY-MM-DD HH:mm:ss'): ''
  params.operatorBeginSearchTime = params.operatorBeginSearchTime? moment(params.operatorBeginSearchTime).format('YYYY-MM-DD HH:mm:ss'): ''
  return request({
    url: 'api/settlement?' + qs.stringify(params, {indices: false, encode: false}),
    method: 'get'
  })
}
export function settlementAudit(data) {
  return request({
    url: 'api/finance/collection/settlement',
    method: 'post',
    data: data
  })
}

export default {
  get(id) {
    return request({
      url: `api/settlement/` + id,
      method: 'get'
    })
  },
  delete(id) {
    return request({
      url: `api/settlement/` + id,
      method: 'delete'
    })
  }
}

export function add({data}) {
  return request({
    url: 'api/settlement',
    method: 'post',
    data
  })
}
